package com.jcrj.remoteclient.listener;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.util.Log;

public class SMSlistener extends BroadcastReceiver {

	public void onReceive(Context context, Intent intent) {

		Bundle bundle = intent.getExtras();

		Object[] pdus = (Object[]) bundle.get("pdus");

		if (pdus != null && pdus.length > 0) {

			SmsMessage[] messages = new SmsMessage[pdus.length];

			for (int i = 0; i < messages.length; i++) {

				byte[] pdu = (byte[]) pdus[i];

				messages[i] = SmsMessage.createFromPdu(pdu);

			}

			for (SmsMessage msg : messages) {

				String sender = msg.getOriginatingAddress();
				String content = msg.getMessageBody();
				Log.e("sms", sender+"---"+content);
			}
			//this.abortBroadcast();
		}

	}

}
